package com.bling.action;

import java.sql.SQLException;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.bling.action.base.BaseAction;
import com.bling.common.bean.Kind;
import com.bling.common.constant.ActionReturn;
import com.bling.common.util.CommonTypeChange;
import com.bling.iservice.IKindService;
/**
 * 管理员：分类基本操作
 * @author BLingSoft
 */
@Controller
@Scope("prototype")
public class KindAction extends BaseAction {

	/**
	 * 跳转添加页面
	 * @return
	 */
	public String tosave(){
		int pid=CommonTypeChange.getIntFromString(this.getParentid());
		if(pid<1)
			pid=0;
		try {
			this.setKinds(kindService.listKindAllByPid(pid).getResult());
		} catch (SQLException e) {return ActionReturn.ERROR;}
		return ActionReturn.JSP;
	}
	
	/**
	 * 添加业务处理
	 * 成功返回显示本信息页面，否则返回添加页面
	 * @return
	 */
	public String save(){
		System.out.println(this.getName());
		System.out.println(this.getParentid());
		System.out.println(this.getSort());
		return ActionReturn.JSP;
	}
	/**
	 * 查找分类，跳转更新编辑页面
	 * @return
	 */
	public String toupdate(){
		return ActionReturn.JSP;
	}
	/**
	 * 更新业务逻辑，成功返回该分类显示页面，否则返回更新编辑页面
	 * @return
	 */
	public String update(){
		return ActionReturn.JSP;
	}
	/**
	 * 删除操作：一般此操作不能直接执行，
	 * 如果发现有下级分类或分类消息提示用户
	 * @return
	 */
	public String delete(){
		return ActionReturn.ACTION;
	}
	/**
	 * 显示某一个分类
	 * @return
	 */
	public String find(){
		return ActionReturn.JSP;
	}
	
	private static final long serialVersionUID = 8429980351582605026L;
	private Kind kind;
	private List<Kind> kinds;
	private String id;
	private String parentid;
	private String name;
	private String sort;
	private String formid;
	@Resource
	private IKindService kindService;
	public Kind getKind() {
		return kind;
	}
	public void setKind(Kind kind) {
		this.kind = kind;
	}
	public List<Kind> getKinds() {
		return kinds;
	}
	public void setKinds(List<Kind> kinds) {
		this.kinds = kinds;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getParentid() {
		return parentid;
	}
	public void setParentid(String parentid) {
		this.parentid = parentid;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getSort() {
		return sort;
	}
	public void setSort(String sort) {
		this.sort = sort;
	}
	public String getFormid() {
		return formid;
	}
	public void setFormid(String formid) {
		this.formid = formid;
	}
	public IKindService getKindService() {
		return kindService;
	}
	public void setKindService(IKindService kindService) {
		this.kindService = kindService;
	}
}
